home *** CD-ROM | disk | FTP | other *** search
- var this_width = 400;
- var this_height = 300;
- var halved_koof = 10;
- var halved_width = this_width / halved_koof;
- var halved_height = this_height / halved_koof;
- var damper = new flash.display.BitmapData(halved_width,halved_height,false,128);
- var result = new flash.display.BitmapData(halved_width,halved_height,false,128);
- var result2 = new flash.display.BitmapData(this_width,this_height,false,128);
- var source = new flash.display.BitmapData(halved_width,halved_height,false,128);
- var buffer = new flash.display.BitmapData(halved_width,halved_height,false,128);
- var output = new flash.display.BitmapData(this_width,this_height,true,128);
- var surface = flash.display.BitmapData.loadBitmap("surface");
- var bounds = new flash.geom.Rectangle(0,0,halved_width,halved_height);
- var origin = new flash.geom.Point();
- var matrix = new flash.geom.Matrix();
- var matrix2 = new flash.geom.Matrix();
- matrix2.a = matrix2.d = halved_koof;
- var wave = new flash.filters.ConvolutionFilter(3,3,[1,1,1,1,1,1,1,1,1],9,0);
- var damp = new flash.geom.ColorTransform(0,0,0.9960937,1,0,0,2,0);
- var water = new flash.filters.DisplacementMapFilter(result2,origin,4,4,32,32,"ignore");
- this.attachBitmap(output,0);
- var ms = getTimer();
- var frame = 0;
- var mouseDown = false;
- this.onMouseUp = function()
- {
- var _loc1_ = _xmouse / halved_koof;
- var _loc2_ = _ymouse / halved_koof;
- source.setPixel(_loc1_ + 1,_loc2_,16777215);
- source.setPixel(_loc1_ - 1,_loc2_,16777215);
- source.setPixel(_loc1_,_loc2_ + 1,16777215);
- source.setPixel(_loc1_,_loc2_ - 1,16777215);
- source.setPixel(_loc1_,_loc2_,16777215);
- };
- var _loc2 = halved_width * Math.random();
- var _loc1 = halved_height * Math.random();
- source.setPixel(_loc2 + 1,_loc1,16777215);
- source.setPixel(_loc2 - 1,_loc1,16777215);
- source.setPixel(_loc2,_loc1 + 1,16777215);
- source.setPixel(_loc2,_loc1 - 1,16777215);
- source.setPixel(_loc2,_loc1,16777215);
- this.onEnterFrame = function()
- {
- if(Math.random() > 0.999)
- {
- var _loc1_ = halved_width * Math.random();
- var _loc2_ = halved_height * Math.random();
- source.setPixel(_loc1_ + 1,_loc2_,16777215);
- source.setPixel(_loc1_ - 1,_loc2_,16777215);
- source.setPixel(_loc1_,_loc2_ + 1,16777215);
- source.setPixel(_loc1_,_loc2_ - 1,16777215);
- source.setPixel(_loc1_,_loc2_,16777215);
- }
- result.applyFilter(source,bounds,origin,wave);
- result.draw(result,matrix,null,"add");
- result.draw(buffer,matrix,null,"difference");
- result.draw(result,matrix,damp);
- result2.draw(result,matrix2,null,null,null,true);
- output.applyFilter(surface,new flash.geom.Rectangle(0,0,this_width,this_height),origin,water);
- buffer = source;
- source = result.clone();
- };
-